import {request,requestMock} from '@/utils/http'

//封装获取三级列表
export const requestCategoryList = () => {
    return request.get('/api/product/getBaseCategoryList')
}

//获取banner
export const requestBannerList = () => {
    return requestMock.get('/banner')
}

//获取floor
export const requestFloorList = () => {
    return requestMock.get('/floor')
}

//获取搜索页数据
export const requestSearchList = (searchParams) => {
    return request.post('/api/list',searchParams)
}

//获取详情页数据
export const requestDetailInfo = (skuId) => {
    return request.get(`/api/item/${skuId}`)
}

//添加购物车或修改购物车
export const requestAddOrUpdateCart = ({skuId,skuNum}) => {
    return request.post(`/api/cart/addToCart/${ skuId }/${ skuNum }`)
}

//获取购物车数据
export const requestShopCart = () => {
    return request.get('/api/cart/cartList')
}

//切换商品选中状态
export const requestIscheckedCart = (skuID,isChecked) => {
    return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`)
}

//切换所有商品选中状态
export const requestIscheckedAll = (skuIdList,isChecked) => {
    return request.post(`/api/cart/batchCheckCart/${isChecked}`,skuIdList)
}

//删除单个商品
export const requestDeleteCart = (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`)
}

//删除所有商品
export const requestDeleteCartAll = (skuIdList) => {
    return request.delete('/api/cart/batchDeleteCart',skuIdList)
}

//获取验证码
export const requestGetRegister = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`)
}

//注册用户
export const requestRegisterUser = (user) => {
    return request.post('/api/user/passport/register',user)
}

//登录请求
export const requestLogin = (userInfo) => {
    return request.post('/api/user/passport/login',userInfo)
}

//使用token获取用户信息
export const requestUserInfo = () => {
    return request.get('/api/user/passport/auth/getUserInfo')
}

//退出登录
export const requestLogOut = () => {
    return request.get('/api/user/passport/logout')
}

//获取订单数据
export const requestTradeInfo = () => {
    return request.get('/api/order/auth/trade')
}

//获取地址信息
export const requestTradeAddress = () => {
    return requestMock.get('/address')
}

//提交订单
export const requestAddTrade = (tradeNo,tradeInfo) => {
    return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeInfo)
}